<?php
declare (strict_types=1);

namespace app\api\controller\v1;

use app\common\model\Collect as CollectModel;

class Collect
{
    /**
     * 个人中心--我的收藏
     */
    public function index()
    {
        return sucessMsg(200, '获取成功', [
            'collect' => $this->collect(),   //获取我的收藏
        ]);
    }

    /**
     * 个人中心--我的收藏
     */
    public function collect()
    {
        $data = CollectModel::where(['status'=>1])
            ->field('id,paper_id,create_at')
            ->order(['id' => 'asc'])
            ->select();
        foreach ($data as &$value) {
            $value['paper_id'] = $value->paper->title;
            unset($value->paper);
        }
        return $data;
    }
}
